home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Design
/
WB Collection.iso
/
workbench werkzeuge
/
bildschirmschoner
/
bserver_v1.5
/
sources.lha
/
Sources
/
lib
/
libsources
/
client_library.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-08
|
24KB
|
980 lines
; /*
echo "Compiling shared library"
if not exists client.library.o
sc libcode nostackcheck constlib streq strmerge ignore=73 define=SHARED optimize optsize optpeep client_library.c DEBUG=LINE
endif
if not exists PTPlay.o
asm -cc -m0 PTPlay.s
endif
slink LIBFD client.fd TO ///Libs/client.library FROM LIB:libent.o LIB:libinit.o client_library.o Decrunch30.o PTPlay.o LIB lib:sc.lib lib:amiga.lib libVersion 1 libRevision 7 libid "client.library 1.8 (8.11.95) Copyright 1994-1995 by Stefano Reksten" SD SC NOICONS STRIPDEBUG
copy ///Libs/client.library LIBS:
;echo "Compiling linked library"
;sc parms=registers optimize optsize constlib nostackcheck streq IGNORE=73 define=LINKED client_library.c
;oml /client.lib r client_library.o
quit
Client.lib 1.8
Copyright © 1994-1995 by Stefano Reksten of 3AM - The Three Amigos!!!
All rights reserved.
*/
#include <exec/memory.h>
#include <intuition/screens.h>
#include <intuition/intuitionbase.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <libraries/iffparse.h>
#include <devices/audio.h>
#include <devices/timer.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <hardware/intbits.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/iffparse.h>
#include <proto/diskfont.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "//include/server.h"
#ifdef SHARED
/****************************
* *
* "LOW-LEVEL" COMMUNICATION *
* PRIMITIVES *
* *
****************************/
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
struct Library *IFFParseBase, *DiskfontBase;
struct DosLibrary *DOSBase;
int __saveds __asm __UserLibInit( register __a6 struct MyLibrary *libbase )
{
int result = 1;
if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 37L ) )
{
if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 37L ) )
{
if ( DOSBase = (struct DosLibrary *)OpenLibrary( "dos.library", 37L ) )
{
if ( IFFParseBase = OpenLibrary( "iffparse.library", 37L ) )
{
if ( DiskfontBase = OpenLibrary( "diskfont.library", 37L ) )
result = 0;
else CloseLibrary( IFFParseBase );
}
else CloseLibrary( (struct Library *)DOSBase );
}
else CloseLibrary( (struct Library *)IntuitionBase );
}
else CloseLibrary( (struct Library *)GfxBase );
}
return result;
}
void __saveds __asm __UserLibCleanup( register __a6 struct MyLibrary *libbase )
{
CloseLibrary( DiskfontBase );
CloseLibrary( IFFParseBase );
CloseLibrary( (struct Library *)DOSBase );
CloseLibrary( (struct Library *)GfxBase );
CloseLibrary( (struct Library *)IntuitionBase );
}
static struct ClientMessage *__asm __saveds __AllocClientMessage( register __d0 ULONG action,register __a1 struct MsgPort *CommunicationPort )
{
struct ClientMessage *bmsg;
if ( bmsg = AllocVec( sizeof(struct ClientMessage), MEMF_PUBLIC | MEMF_CLEAR ) )
{
bmsg->cm_Msg.mn_Node.ln_Type = NT_MESSAGE;
bmsg->cm_Msg.mn_ReplyPort = CommunicationPort;
bmsg->cm_Msg.mn_Length = sizeof(struct ClientMessage);
bmsg->cm_Action = action;
}
return( bmsg );
}
static void __asm __saveds __FreeClientMessage( register __a1 struct ClientMessage *bmsg )
{
FreeVec( bmsg );
}
BOOL __asm __saveds __SendClientMsg( register __d0 ULONG action, register __a1 struct MsgPort *CommunicationPort )
{
struct MsgPort *ServerPort;
struct ClientMessage *bmsg, *replymsg = NULL;
BOOL talked = FALSE;
if ( bmsg = __AllocClientMessage( action, CommunicationPort ) )
{
Forbid();
if ( ServerPort = FindPort( SERVERPORTNAME ) )
PutMsg( ServerPort, (struct Message *)bmsg );
Permit();
if ( ServerPort )
{
while ( !replymsg )
{
WaitPort( CommunicationPort );
replymsg = (struct ClientMessage *)GetMsg( CommunicationPort );
}
talked = TRUE;
}
__FreeClientMessage( bmsg );
}
return( talked );
}
ULONG __asm __saveds __GetServerCommand( register __a1 struct MsgPort *CommunicationPort )
{
register struct ServerMessage *msg;
register ULONG command;
if ( msg = (struct ServerMessage *)GetMsg( CommunicationPort ) )
{
command = msg->sm_Command;
ReplyMsg( (struct Message *)msg );
return( command );
}
else
return( COMMAND_IDLE );
}
ULONG __asm __saveds __WaitServerCommand( register __a1 struct MsgPort *CommunicationPort )
{
WaitPort( CommunicationPort );
return( __GetServerCommand( CommunicationPort ) );
}
struct DisplayIDInformation * __asm __saveds __OpenCommunication( register __a1 struct MsgPort **mp )
{
struct MsgPort *ServerPort;
struct MsgPort *CommunicationPort;
struct ClientMessage *cm, *replymsg = NULL;
struct DisplayIDInformation *dinfo;
BOOL talked = FALSE;
if ( CommunicationPort = CreateMsgPort() )
{
if ( cm = __AllocClientMessage( ACTION_ARRIVED, CommunicationPort ) )
{
Forbid();
if ( ServerPort = FindPort( SERVERPORTNAME ) )
PutMsg( ServerPort, (struct Message *)cm );
Permit();
if ( ServerPort )
{
while ( !replymsg )
{
WaitPort( CommunicationPort );
replymsg = (struct ClientMessage *)GetMsg( CommunicationPort );
}
talked = TRUE;
dinfo = replymsg->DInfo;
*mp = CommunicationPort;
}
__FreeClientMessage( cm );
if ( talked )
{
SetTaskPri( FindTask( NULL ), -5 );
return dinfo;
}
}
DeleteMsgPort( CommunicationPort );
}
return NULL;
}
/*****************
* *
* User functions *
* *
*****************/
BOOL __asm __saveds CheckAA( void )
{
return (BOOL)((GfxBase->LibNode.lib_Version >= 39) && (GfxBase->ChipRevBits0 & 1<<GFXB_AA_ALICE));
}
struct Screen * __asm __saveds CloneFrontmostScreen( register __d0 UBYTE brightness )
{
register struct Screen *cloned, *fm;
register int depth, n;
register ULONG *RGBTriplets, *copy_of_RGBTriplets;
Forbid();
fm = IntuitionBase->FirstScreen;
depth = fm->RastPort.BitMap->Depth;
if ( RGBTriplets = AllocVec( 3088, MEMF_ANY|MEMF_CLEAR ) )
{
copy_of_RGBTriplets = (ULONG *)((ULONG)RGBTriplets + 4);
*RGBTriplets = ( 1 << depth ) << 16;
cloned = OpenScreenTags( NULL,
SA_Left, fm->LeftEdge,
SA_Top, 0,
SA_Width, fm->Width,
SA_Height, fm->Height,
SA_Depth, depth,
SA_DisplayID, GetVPModeID( &fm->ViewPort ),
SA_Font, fm->Font,
SA_Behind, TRUE,
TAG_END );
if ( cloned )
{
GetRGB32( fm->ViewPort.ColorMap, 0, 1<<depth, copy_of_RGBTriplets );
for ( n = 0; n < 3 << depth; n++ )
{
*copy_of_RGBTriplets = (((*copy_of_RGBTriplets) >> 24) * brightness / 100 ) << 24;
copy_of_RGBTriplets++;
}
LoadRGB32( &cloned->ViewPort, RGBTriplets );
BltBitMap( fm->RastPort.BitMap, 0, 0,
cloned->RastPort.BitMap, 0, 0,
fm->Width, fm->Height, 0xC0, 0xFF, NULL );
ScreenToFront( cloned );
}
FreeVec( RGBTriplets );
}
Permit();
return( cloned );
}
ULONG __asm __saveds DarkestColorIndex( register __a1 struct Screen *scr )
{
register ULONG *RGBTriplets, *copy_of_RGBTriplets;
register ULONG color_index = 0, minbri = 0xFFFFFFFF, bri, n;
register ULONG r, g, b;
register ULONG colors_to_get = 1L<<scr->RastPort.BitMap->Depth;
if ( RGBTriplets = AllocVec( 3072, MEMF_ANY|MEMF_CLEAR ) )
{
copy_of_RGBTriplets = RGBTriplets;
GetRGB32( scr->ViewPort.ColorMap, 0, colors_to_get, (APTR)RGBTriplets );
for ( n = 0; n < colors_to_get; n++ )
{
r = (*copy_of_RGBTriplets++) >> 24;
g = (*copy_of_RGBTriplets++) >> 24;
b = (*copy_of_RGBTriplets++) >> 24;
bri = r * r + g * g + b * b;
if ( bri < minbri )
{
color_index = n;
minbri = bri;
}
}
FreeVec( RGBTriplets );
return color_index;
}
else return 0;
}
ULONG __asm __saveds BrightestColorIndex( register __a1 struct Screen *scr )
{
register ULONG *RGBTriplets, *copy_of_RGBTriplets;
register ULONG color_index = 0, maxbri = 0, bri, n;
register ULONG r, g, b;
register ULONG colors_to_get = 1L<<scr->RastPort.BitMap->Depth;
if ( RGBTriplets = AllocVec( 3072, MEMF_ANY|MEMF_CLEAR ) )
{
copy_of_RGBTriplets = RGBTriplets;
GetRGB32( scr->ViewPort.ColorMap, 0, colors_to_get, (APTR)RGBTriplets );
for ( n = 0; n < colors_to_get; n++ )
{
r = (*copy_of_RGBTriplets++) >> 24;
g = (*copy_of_RGBTriplets++) >> 24;
b = (*copy_of_RGBTriplets++) >> 24;
bri = r * r + g * g + b * b;
if ( bri > maxbri )
{
color_index = n;
maxbri = bri;
}
}
FreeVec( RGBTriplets );
return color_index;
}
else return 0;
}
struct Screen * __asm __saveds GetDeeperFrontmostScreen( register __d0 UBYTE brightness, register __d1 UBYTE imagedepth )
{
register struct Screen *cloned = NULL, *fm;
register int depth, fmdepth;
register ULONG *RGBTriplets, *copy_of_RGBTriplets, vpmode;
Forbid();
fm = IntuitionBase->FirstScreen;
fmdepth = fm->RastPort.BitMap->Depth;
vpmode = GetVPModeID( &fm->ViewPort );
if ( fmdepth >= 7 || vpmode & HAM || vpmode & EXTRA_HALFBRITE )
{
Permit();
return NULL;
}
if ( imagedepth <= fmdepth )
depth = fmdepth + 1;
else
depth = imagedepth + 1;
if ( RGBTriplets = AllocVec( 3088, MEMF_ANY|MEMF_CLEAR ) )
{
copy_of_RGBTriplets = (ULONG *)((ULONG)RGBTriplets + 4);
if ( cloned = OpenScreenTags( NULL,
SA_Left, fm->LeftEdge,
SA_Width, fm->Width,
SA_Height, fm->Height,
SA_Depth, depth,
SA_DisplayID, vpmode,
SA_Font, fm->Font,
SA_Behind, TRUE,
TAG_END ) )
{
register UWORD *plane;
register ULONG n;
GetRGB32( fm->ViewPort.ColorMap, 0, 1<<fmdepth, copy_of_RGBTriplets );
for ( n = 0; n < 3 << fmdepth; n++ )
{
*copy_of_RGBTriplets = (((*copy_of_RGBTriplets) >> 24) * brightness / 100 ) << 24;
copy_of_RGBTriplets++;
}
*RGBTriplets = (1L<<fmdepth+16) + (1L<<depth-1);
LoadRGB32( &cloned->ViewPort, RGBTriplets );
*RGBTriplets = (1L<<fmdepth+16);
LoadRGB32( &cloned->ViewPort, RGBTriplets );
BltBitMap( fm->RastPort.BitMap, 0, 0,
cloned->RastPort.BitMap, 0, 0,
fm->Width, fm->Height, 0xC0, 0xFF, NULL );
plane = (UWORD *)cloned->RastPort.BitMap->Planes[depth-1];
n = ( cloned->RastPort.BitMap->Rows * cloned->RastPort.BitMap->BytesPerRow ) >> 1;
while( n-- )
*plane++ = 0xFFFF;
ScreenToFront( cloned );
}
FreeVec( RGBTriplets );
}
Permit();
return( cloned );
}
/***********************************************/
/* New sound supporting functions */
/***********************************************/
static UBYTE whichChannel[4] = { 1, 2, 4, 8 };
static BYTE codeToDelta[16] = { -34, -21, -13, -8, -5, -3, -2, -1, 0, 1, 2, 3, 5, 8, 13, 21 };
#define ID_VHDR MAKE_ID('V','H','D','R')
#define ID_BODY MAKE_ID('B','O','D','Y')
#define ID_8SVX MAKE_ID('8','S','V','X')
typedef struct {
ULONG oneShotHiSamples, repeatHiSamples, samplesPerCycle;
UWORD samplesPerSec;
UBYTE ctOctave, sCompression;
LONG volume; } Voice8Header;
#define sCmpFibDelta 1
Sound * __asm __saveds Open8SVX( register __a1 char *iffname )
{
Sound *svx;
register struct IFFHandle *ih;
BOOL error = TRUE;
LONG ifferr;
if ( !iffname )
return 0L;
if ( svx = AllocVec( sizeof(Sound), MEMF_ANY|MEMF_CLEAR ) )
{
if ( ih = AllocIFF() )
{
if ( ih->iff_Stream = (ULONG)Open( iffname, MODE_OLDFILE ) )
{
InitIFFasDOS( ih );
if ( 0 == OpenIFF( ih, IFFF_READ ) )
{
PropChunk( ih, ID_8SVX, ID_VHDR );
PropChunk( ih, ID_8SVX, ID_BODY );
StopOnExit( ih, ID_8SVX, ID_FORM );
ifferr = ParseIFF( ih, IFFPARSE_SCAN );
if ( !ifferr || ifferr == IFFERR_EOF || ifferr == IFFERR_EOC )
{
register struct StoredProperty *sp;
register Voice8Header *vh;
UBYTE *bdy;
if ( sp = FindProp( ih, ID_8SVX, ID_VHDR ) )
{
vh = (Voice8Header *)sp->sp_Data;
svx->Volume = 64 * vh->volume / 65536;
svx->Period = vh->samplesPerSec;
svx->DataLength = vh->oneShotHiSamples + vh->repeatHiSamples;
if ( sp = FindProp( ih, ID_8SVX, ID_BODY ) )
{
bdy = (UBYTE *)sp->sp_Data;
if ( vh->sCompression == sCmpFibDelta )
{
if ( svx->AudioData = AllocVec( 2 * ( svx->DataLength - 2 ), MEMF_CHIP ) )
{
LONG i;
BYTE d, x = bdy[1];
for ( i = 0; i < svx->DataLength << 1; i++ )
{
d = bdy[i>>1];
if ( i & 1 )
d &= 0x0F;
else
d >>= 4;
x += codeToDelta[d];
svx->AudioData[i] = x;
}
error = FALSE;
}
}
else
if ( svx->AudioData = AllocVec( svx->DataLength, MEMF_CHIP ) )
{
CopyMem( bdy, svx->AudioData, svx->DataLength );
error = FALSE;
}
}
}
}
}
Close( ih->iff_Stream );
}
FreeIFF( ih );
}
if ( error )
{
FreeVec( svx );
svx = NULL;
}
}
return svx;
}
void __asm __saveds Play8SVX( register __a1 Sound *svx, register __d0 UBYTE volume )
{
struct MsgPort *MP;
BOOL SoundPlayed = FALSE;
if ( !svx )
return;
if ( MP = CreatePort( NULL, NULL ) )
{
struct IOAudio *AudioIO;
if ( AudioIO = (struct IOAudio *)AllocVec( sizeof(struct IOAudio), MEMF_PUBLIC | MEMF_CLEAR ) )
{
AudioIO->ioa_Request.io_Message.mn_ReplyPort = MP;
AudioIO->ioa_Request.io_Message.mn_Node.ln_Pri = 127;
AudioIO->ioa_Request.io_Command = ADCMD_ALLOCATE;
AudioIO->ioa_Request.io_Flags = ADIOF_NOWAIT;
AudioIO->ioa_AllocKey = 0;
AudioIO->ioa_Data = whichChannel;
AudioIO->ioa_Length = sizeof(whichChannel);
if ( !OpenDevice( "audio.device", 0L, (struct IORequest *)AudioIO, 0L ) )
{
AudioIO->ioa_Request.io_Message.mn_ReplyPort = MP;
AudioIO->ioa_Request.io_Command = CMD_WRITE;
AudioIO->ioa_Request.io_Flags = ADIOF_PERVOL;
AudioIO->ioa_Data = svx->AudioData;
AudioIO->ioa_Length = svx->DataLength;
AudioIO->ioa_Period = (( GfxBase->DisplayFlags & PAL ) ? 3546895L : 3579545L) / svx->Period;
AudioIO->ioa_Volume = volume;
AudioIO->ioa_Cycles = 1;
BeginIO( (struct IORequest *)AudioIO );
WaitPort( MP );
SoundPlayed = TRUE;
CloseDevice( (struct IORequest *)AudioIO );
}
DeleteExtIO( (struct IORequest *)AudioIO );
}
if ( !SoundPlayed )
{
struct timerequest *TimerIO;
if ( TimerIO = (struct timerequest *)CreateExtIO( MP, sizeof(struct timerequest) ) )
{
if ( !OpenDevice( "timer.device", UNIT_MICROHZ, TimerIO, 0 ) )
{
TimerIO->tr_node.io_Command = TR_ADDREQUEST;
TimerIO->tr_time.tv_secs = svx->DataLength / svx->Period;
TimerIO->tr_time.tv_micro = svx->DataLength % svx->Period;
DoIO( (struct IORequest *)TimerIO );
CloseDevice( (struct IORequest *)TimerIO );
}
DeleteExtIO( (struct IORequest *)TimerIO );
}
}
DeletePort( MP );
}
}
static void __asm __saveds Complete8SVX( register __a1 Sound *svx )
{
if ( svx->AudioIO )
{
register struct MsgPort *mp = svx->AudioIO->ioa_Request.io_Message.mn_ReplyPort;
CloseDevice( (struct IORequest *)svx->AudioIO );
DeleteExtIO( (struct IORequest *)svx->AudioIO );
DeletePort( mp );
svx->AudioIO = NULL;
}
}
void __asm __saveds PlayAsynch8SVX( register __a1 Sound *svx, register __d0 UBYTE volume )
{
struct MsgPort *AudioMP;
struct IOAudio *AudioIO;
if ( !svx )
return;
Complete8SVX( svx );
if ( AudioMP = CreatePort( NULL, NULL ) )
{
if ( AudioIO = (struct IOAudio *)AllocVec( sizeof(struct IOAudio), MEMF_PUBLIC | MEMF_CLEAR ) )
{
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
AudioIO->ioa_Request.io_Message.mn_Node.ln_Pri = 127;
AudioIO->ioa_Request.io_Command = ADCMD_ALLOCATE;
AudioIO->ioa_Request.io_Flags = ADIOF_NOWAIT;
AudioIO->ioa_AllocKey = 0;
AudioIO->ioa_Data = whichChannel;
AudioIO->ioa_Length = sizeof(whichChannel);
if ( !OpenDevice( "audio.device", 0L, (struct IORequest *)AudioIO, 0L ) )
{
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
AudioIO->ioa_Request.io_Command = CMD_WRITE;
AudioIO->ioa_Request.io_Flags = ADIOF_PERVOL;
AudioIO->ioa_Data = svx->AudioData;
AudioIO->ioa_Length = svx->DataLength;
AudioIO->ioa_Period = (( GfxBase->DisplayFlags & PAL ) ? 3546895L : 3579545L) / svx->Period;
AudioIO->ioa_Volume = volume;
AudioIO->ioa_Cycles = 1;
svx->AudioIO = AudioIO;
BeginIO( (struct IORequest *)AudioIO );
}
else
{
DeleteExtIO( (struct IORequest *)AudioIO );
DeletePort( AudioMP );
}
}
else DeletePort( AudioMP );
}
}
void __asm __saveds Close8SVX( register __a1 Sound *svx )
{
if ( svx )
{
Complete8SVX( svx );
FreeVec( svx->AudioData );
FreeVec( svx );
}
}
/** Module stuff **/
void __asm __saveds InitModule( register __a1 Module * );
BOOL __asm __saveds PlayModule( register __a1 Module * );
void __asm __saveds StopModule( register __a1 Module * );
void __asm __saveds FreeModule( register __a1 Module * );
char * __asm __saveds GetEquilizers( register __a1 Module * );
Module * __asm __saveds OpenModule( register __a1 char *modulename )
{
BPTR handle, lock;
Module *mod;
ULONG *mem;
struct FileInfoBlock fib;
if ( mod = AllocVec( sizeof(Module), MEMF_ANY | MEMF_CLEAR ) )
{
if ( lock = Lock( modulename, ACCESS_READ ) )
{
if ( Examine( lock, &fib ) && ( fib.fib_DirEntryType < 0 ) )
{
if ( handle = Open( modulename, MODE_OLDFILE ) )
{
if ( mod->m_Data = mem = AllocVec( fib.fib_Size, MEMF_CHIP ) )
{
if ( Read( handle, mem, fib.fib_Size ) == fib.fib_Size )
{
if ( mem[270] == MAKE_ID( 'M','.','K','.' ) )
{
InitModule( mod );
Close( handle );
UnLock( lock );
return mod;
}
}
FreeVec( mem );
}
Close( handle );
}
}
UnLock( lock );
}
FreeVec( mod );
}
return NULL;
}
void __asm __saveds InitModule( register __a1 Module *module )
{
extern void __asm pt_InitMusic( register __a0 APTR mod_data );
extern void __interrupt GoPlay( void );
if ( module )
{
if ( module->m_IntInstalled )
StopModule( module );
module->m_Int.is_Data = module->m_Data;
module->m_Int.is_Code = GoPlay;
module->m_Int.is_Node.ln_Pri = 5;
module->m_Int.is_Node.ln_Type = NT_INTERRUPT;
module->m_Int.is_Node.ln_Name = "BServer_PT_Int";
pt_InitMusic( module->m_Data );
}
}
BOOL __asm __saveds PlayModule( register __a1 Module *module )
{
if ( module && (module->m_IntInstalled == FALSE) )
{
struct IOAudio AudioIO;
struct MsgPort *mp;
UBYTE channel[] = { 1+2+4+8 }; /*All the channels */
if ( mp = CreateMsgPort() )
{
memset( &AudioIO, 0, sizeof(struct IOAudio) );
AudioIO.ioa_Request.io_Message.mn_ReplyPort = mp;
AudioIO.ioa_Request.io_Message.mn_Node.ln_Pri = -80;
AudioIO.ioa_Request.io_Command = ADCMD_ALLOCATE;
AudioIO.ioa_Request.io_Flags = ADIOF_NOWAIT;
AudioIO.ioa_Data = channel;
AudioIO.ioa_Length = sizeof(channel);
if ( !OpenDevice( "audio.device", 0L, (struct IORequest *)&AudioIO, 0L ) )
{
CloseDevice( &AudioIO );
AddIntServer( INTB_VERTB, &module->m_Int );
module->m_IntInstalled = TRUE;
}
DeleteMsgPort( mp );
}
}
return module->m_IntInstalled;
}
void __asm __saveds StopModule( register __a1 Module *module )
{
extern void __asm pt_StopMusic( void );
if ( module && (module->m_IntInstalled == TRUE) )
{
RemIntServer( INTB_VERTB, &module->m_Int );
module->m_IntInstalled = FALSE;
pt_StopMusic();
}
}
void __asm __saveds FreeModule( register __a1 Module *module )
{
if ( module != NULL )
{
if ( module->m_IntInstalled )
StopModule( module );
FreeVec( module->m_Data );
FreeVec( module );
}
}
char * __asm __saveds GetEquilizers( register __a1 Module *mod )
{
extern far char pt_Equilizers[];
return pt_Equilizers;
}
/*************************************/
/* */
/* Arguments passing related stuff */
/* */
/*************************************/
char * __asm GetArgString( register __a0 char *line, register __a1 char *hdr, register __d0 char *store )
{
char *s, *ln = line;
if ( !*line || !*hdr )
return 0L;
while ( 1 )
{
s = hdr;
while( *ln && (*ln == ' ' || *ln == '\t') )
ln++;
if ( !*ln )
return 0L;
while ( *s && *ln && ((*s++|32)==(*ln++|32)) );
if ( !*s && ( !*ln || *ln == ' ' || *ln == '\t' || *ln == '=' ) )
{
while( *ln && (*ln == ' ' || *ln == '\t' || *ln == '=' ) )
ln++;
if ( *ln && store )
{
char *ln2 = ln;
if ( *ln2 == 39 ) /* ' */
{
ln2++;
while ( *ln2 && *ln2 != 39 )
*store++ = *ln2++;
}
else if ( *ln2 == 34 ) /* " */
{
ln2++;
while ( *ln2 && *ln2 != 34 )
*store++ = *ln2++;
}
else
while ( *ln2 && *ln2 != ' ' )
*store++ = *ln2++;
*store = 0;
}
return ln;
}
while ( *ln && *ln != ' ' && *ln != '\t' )
ln++;
}
}
BOOL __asm GetArgInt( register __a0 char *line, register __a1 char *hdr, register __d0 int *store )
{
register char *rs;
register int result;
if ( rs = GetArgString( line, hdr, NULL ) )
{
result = *rs++ - '0';
while ( *rs >= '0' && *rs <= '9' )
result = 10 * result + *rs++ - '0';
*store = result;
return TRUE;
}
else
return FALSE;
}
/*********************
* *
* Font related stuff *
* *
*********************/
/*
extern int atoi( const char * );
void __asm ObtainAnyFont( register __a0 struct DisplayIDInformation *dinfo )
{
struct TextAttr *ta;
struct TextFont *tf;
char *buff;
if ( ta = (struct TextAttr *)AllocVec( sizeof(struct TextAttr), MEMF_ANY|MEMF_CLEAR ) )
{
ta->ta_Flags = FPF_DISKFONT;
ta->ta_YSize = 20;
if ( buff = AllocVec( 36, MEMF_ANY|MEMF_CLEAR ) )
{
ta->ta_Name = buff;
strcpy( buff, "diamond.font" );
dinfo->di_TextAttr = ta;
if ( GetArgString( dinfo->di_Args, "FONTHEIGHT", buff ) )
ta->ta_YSize = atoi( buff );
else
ta->ta_YSize = 20;
if ( 0 == GetArgString( dinfo->di_Args, "FONTNAME", buff ) )
strcpy( buff, "diamond.font" );
if ( tf = OpenDiskFont( ta ) )
{
dinfo->di_Font = tf;
return;
}
strcpy( buff, "diamond.font" );
ta->ta_YSize = 20;
if ( tf = OpenDiskFont( ta ) )
{
dinfo->di_Font = tf;
return;
}
strcpy( buff, "times.font" );
ta->ta_YSize = 24;
if ( tf = OpenDiskFont( ta ) )
{
dinfo->di_Font = tf;
return;
}
strcpy( buff, "topaz.font" );
ta->ta_YSize = 8;
ta->ta_Flags = FPF_ROMFONT;
dinfo->di_Font = OpenFont( ta );
}
else FreeVec( ta );
}
}
*/
#endif
#ifdef LINKED
#include "//include/client_pragmas.h"
/***********************
* *
* Server.lib functions *
* *
***********************/
struct Library *ClientBase;
static struct MsgPort *CommunicationPort;
struct DisplayIDInformation *__asm __saveds OpenCommunication( void )
{
register struct DisplayIDInformation *dinfo;
if ( ClientBase = OpenLibrary( "client.library", 0L ) )
{
if ( dinfo = __OpenCommunication( &CommunicationPort ) )
return dinfo;
CloseLibrary( ClientBase );
}
return NULL;
}
void __asm __saveds CloseCommunication( register __a1 struct DisplayIDInformation *dinfo )
{
if ( CommunicationPort ) DeleteMsgPort( CommunicationPort );
if ( dinfo ) FreeVec( dinfo );
if ( ClientBase ) CloseLibrary( ClientBase );
}
BOOL __asm __saveds SendClientMsg( register __d0 ULONG action )
{
return __SendClientMsg( action, CommunicationPort );
}
ULONG __asm __saveds GetServerCommand( void )
{
return __GetServerCommand( CommunicationPort );
}
ULONG __asm __saveds WaitServerCommand( void )
{
return __WaitServerCommand( CommunicationPort );
}
extern far struct Custom custom;
void __asm __saveds SpritesOff( void )
{
OFF_SPRITE
custom.spr[0].ctl=0;
custom.spr[1].ctl=0;
custom.spr[2].ctl=0;
custom.spr[3].ctl=0;
custom.spr[4].ctl=0;
custom.spr[5].ctl=0;
custom.spr[6].ctl=0;
custom.spr[7].ctl=0;
}
void __asm __saveds SpritesOn( void )
{
ON_SPRITE
}
#endif